package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysWorkerMoney;
import com.ruoyi.project.system.service.ISysWorkerMoneyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 余额明细Controller
 * 
 * @author jjp
 * @date 2020-04-27
 */
@RestController
@Api("余额明细")
@RequestMapping("/system/workMoney")
public class SysWorkerMoneyController extends BaseController
{
    @Autowired
    private ISysWorkerMoneyService sysWorkerMoneyService;

    /**
     * 查询余额明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:money:list')")
    @ApiOperation("查询余额明细列表")
    @GetMapping("/list")
    public TableDataInfo list(SysWorkerMoney sysWorkerMoney)
    {
        startPage();
        List<SysWorkerMoney> list = sysWorkerMoneyService.selectSysWorkerMoneyList(sysWorkerMoney);
        return getDataTable(list);
    }

    /**
     * 获取余额明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:money:query')")
    @ApiOperation("获取余额明细详细信息")
    @GetMapping(value = "/{moneyId}")
    public AjaxResult getInfo(@PathVariable("moneyId") Long moneyId)
    {
        return AjaxResult.success(sysWorkerMoneyService.selectSysWorkerMoneyById(moneyId));
    }

    /**
     * 新增余额明细
     */
    @PreAuthorize("@ss.hasPermi('system:money:add')")
    @ApiOperation("新增余额明细")
    @Log(title = "余额明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWorkerMoney sysWorkerMoney)
    {
        return toAjax(sysWorkerMoneyService.insertSysWorkerMoney(sysWorkerMoney));
    }

    /**
     * 修改余额明细
     */
    @PreAuthorize("@ss.hasPermi('system:money:edit')")
    @ApiOperation("修改余额明细")
    @Log(title = "余额明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWorkerMoney sysWorkerMoney)
    {
        return toAjax(sysWorkerMoneyService.updateSysWorkerMoney(sysWorkerMoney));
    }

    /**
     * 删除余额明细
     */
    @PreAuthorize("@ss.hasPermi('system:money:remove')")
    @ApiOperation("删除余额明细")
    @Log(title = "余额明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{moneyIds}")
    public AjaxResult remove(@PathVariable Long[] moneyIds)
    {
        return toAjax(sysWorkerMoneyService.deleteSysWorkerMoneyByIds(moneyIds));
    }
}
